package com.baigt.jvm.gc;

/**
 * java命令行工具使用
 *


 jps
 -----------
 jps -vm
 jps -参数

 jconsole
 -------------
 图形监控工具


 jvisualvm
 ----------------
 图形监控工具

 jmc  java任务控制(功能更多)
 -----------
 图形监控工具

 使用飞行记录器，可以查看热点代码、调用树、io、内存等

 jmap
 ---------------------------
 java内存映射工具
 jmap -heap 9244
 jmap 参数 pid

 jstat
 ------------
 java统计信息
 jstat -gc 9244
 jstat 参数 pid

 jstat -options
     -class
     -compiler
     -gc
     -gccapacity
     -gccause
     -gcmetacapacity
     -gcnew
     -gcnewcapacity
     -gcold
     -gcoldcapacity
     -gcutil
     -printcompilation

    结果是可用参数列表

 jcmd
 ---------------------------
 java命令
 jcmd 9244 help
 jcmd pid  参数
 当前vm可用参数
     jcmd 9244 help
     9244:
     The following commands are available:
     JFR.stop
     JFR.start
     JFR.dump
     JFR.check
     VM.native_memory
     VM.check_commercial_features
     VM.unlock_commercial_features
     ManagementAgent.stop
     ManagementAgent.start_local
     ManagementAgent.start
     GC.rotate_log
     Thread.print
     GC.class_stats
     GC.class_histogram
     GC.heap_dump
     GC.run_finalization
     GC.run
     VM.uptime
     VM.flags
     VM.system_properties
     VM.command_line
     VM.version
     help

 jcmd 9244 help VM.flags

 jcmd 9244 PerfCounter.print
 打印性能相关的参数


    jstack
 -------------------------------
 查看线程的堆栈信息（可以查看死锁之类，线程状态等）
 jstack pid

 jhat  主要对堆转储文件进行分析(也可以生成) 支持OQL查询(http文档的最后有帮助文档)
 --------------------------
 jhat java_pid1416.hprof
 D:\IdeaProjects\course>jhat java_pid1416.hprof
 Reading from java_pid1416.hprof...
 Dump file created Mon Nov 18 17:34:35 CST 2019
 Snapshot read, resolving...
 Resolving 250930 objects...
 Chasing references, expect 50 dots..................................................
 Eliminating duplicate references..................................................
 Snapshot resolved.
 Started HTTP server on port 7000
 Server is ready.



 C:\Users\Administrator>jps
 11236
 12004
 13384 Main
 13800 Jps
 7240 JavaCommandUtilsDemo
 14332 Launcher
 9244 GCDeadLockDemo

 C:\Users\Administrator>jmap -clstats 7240
 Attaching to process ID 7240, please wait...
 Debugger attached successfully.
 Server compiler detected.
 JVM version is 25.45-b02
 finding class loader instances ..done.
 computing per loader stat ..done.
 please wait.. computing liveness...........done.
 class_loader    classes bytes   parent_loader   alive?  type

 <bootstrap>     598     1117782   null          live    <internal>
 0x000000076b38e538      0       0         null          live    sun/misc/Launcher$ExtClassLoader@0x00000007c000fa10
 0x000000076b3a57d0      23      67268   0x000000076b38e538      live    sun/misc/Launcher$AppClassLoader@0x00000007c000f668
 0x000000076b9b2250      0       0       0x000000076b3a57d0      live    java/util/ResourceBundle$RBClassLoader@0x00000007c00638a8

 total = 4       621     1185050     N/A         alive=4, dead=0     N/A
 */
public class JavaCommandUtilsDemo {
    public static void main(String[] args) {
        for (;;) {
            // do nothing
        }
    }
}
